package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookInArchivedOrder;
import com.pgybook.db.entity.domain.BookInArchivedOrderEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookInArchivedOrderMapper {
    int countByExample(BookInArchivedOrderEx example);

    int deleteByExample(BookInArchivedOrderEx example);

    @Delete({
            "delete from bookinarchivedorder",
            "where INSTANCEID = #{instanceid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long instanceid);

    @Insert({
            "insert into bookinarchivedorder (BOOKINORDER, BOOKINORDERHISTORYID, ",
            "BOOKINORDERID, SRCSTATUS, ",
            "DSTSTATUS, CRTTIME, ",
            "CRTSTAFF)",
            "values (#{bookinorder,jdbcType=BIGINT}, #{bookinorderhistoryid,jdbcType=BIGINT}, ",
            "#{bookinorderid,jdbcType=BIGINT}, #{srcstatus,jdbcType=INTEGER}, ",
            "#{dststatus,jdbcType=INTEGER}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{crtstaff,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "instanceid", before = false, resultType = Long.class)
    int insert(BookInArchivedOrder record);

    int insertSelective(BookInArchivedOrder record);

    List<BookInArchivedOrder> selectByExample(BookInArchivedOrderEx example);

    @Select({
            "select",
            "INSTANCEID, BOOKINORDER, BOOKINORDERHISTORYID, BOOKINORDERID, SRCSTATUS, DSTSTATUS, ",
            "CRTTIME, CRTSTAFF",
            "from bookinarchivedorder",
            "where INSTANCEID = #{instanceid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    BookInArchivedOrder selectByPrimaryKey(Long instanceid);

    int updateByExampleSelective(@Param("record") BookInArchivedOrder record, @Param("example") BookInArchivedOrderEx example);

    int updateByExample(@Param("record") BookInArchivedOrder record, @Param("example") BookInArchivedOrderEx example);

    int updateByPrimaryKeySelective(BookInArchivedOrder record);

    @Update({
            "update bookinarchivedorder",
            "set BOOKINORDER = #{bookinorder,jdbcType=BIGINT},",
            "BOOKINORDERHISTORYID = #{bookinorderhistoryid,jdbcType=BIGINT},",
            "BOOKINORDERID = #{bookinorderid,jdbcType=BIGINT},",
            "SRCSTATUS = #{srcstatus,jdbcType=INTEGER},",
            "DSTSTATUS = #{dststatus,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER}",
            "where INSTANCEID = #{instanceid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BookInArchivedOrder record);
}
